<?php

namespace app\data\controller\record;

use app\data\service\UserAdminService;
use think\admin\Controller;

/**
 * 未匹配数据
 * Class UnmatchedData
 * @package app\data\controller
 */
class UnmatchedData extends Controller
{
    /**
     * 指定数据表
     * @var string
     */
    protected $table = 'message_group';

    /**
     * 未匹配数据管理
     * @auth true
     * @menu true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        $this->title = '未匹配数据管理';
        $this->_query($this->table)->where('is_deal', 2)->order('id desc')->page();
    }

    /**
     * 数据列表处理
     * @param array $list
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _index_page_filter(&$list)
    {
    }

    /**
     * 编辑未匹配数据
     * @auth true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function show()
    {
        $this->title = '查看未匹配数据';
        $this->isAddMode = '0';
        $this->_form($this->table, 'form');
    }

    /**
     * 表单数据处理
     * @param array $data
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _form_filter(&$data)
    {
        if ($this->request->isGet()) {
        } elseif ($this->request->isPost()) {
        }
    }

    /**
     * 表单结果处理
     * @param boolean $result
     */
    protected function _form_result($result)
    {
        if ($result && $this->request->isPost()) {
            $this->success('未匹配数据编辑成功！', 'javascript:history.back()');
        }
    }

    /**
     * 处理未匹配数据
     * @throws \think\Exception
     */
    public function deal()
    {
        $this->_query($this->table)->where(['id' => $this->request->post('id')])->update(['is_deal' => 3]);
        $this->success('处理成功！');
    }

}
